import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {path: '/signup', component: _import('signup/signup'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  },
  {
    path: '/dashboard',
    component: Layout,
    name: '首页',
    children: [{
      path: '', component: _import('dashboard/index'),
      meta: {title: 'Dashboard', icon: 'table'},
    }]
  }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
export const asyncRouterMap = [
  
  {
    path: '/user',
    component: Layout,
    name: 'user',
    meta: {title: '用户权限', icon: 'table'},
    children: [
      {
        path: 'user', 
        name: '用户列表', 
        component: _import('user/user'), 
        meta: {title: '用户列表', icon: 'user'}, 
        menu: 'user'
      },
      {
        path: 'role',
        name: '权限管理',
        component: _import('user/role'),
        meta: {title: '权限管理', icon: 'password'},
        menu: 'role'
      },
    ]
  },
  {
    path: '/devices',
    component: Layout,
    name: 'devices',
    meta: {title: '设备管理', icon: 'password'},
    children: [
      {
        path: 'dev_add_del', 
        name: '设备增删', 
        component: _import('devices/devaddel'), 
        meta: {title: '设备增删', icon: 'example'}, 
        menu: 'dev_add_del'
      },
      {
        path: 'dev_serve',
        name: '设备维护',
        component: _import('devices/devserve'),
        meta: {title: '设备维护', icon: 'example'},
        menu: 'dev_update'
      },
      {
        path: 'dev_approve',
        name: '设备审批',
        component: _import('devices/devapprove'),
        meta: {title: '设备审批', icon: 'example'},
        menu: 'dev_update'
      },
    ]
  },
  {
    path: '/project',
    component: Layout,
    name: 'project',
    meta: {title: '项目管理', icon: 'password'},
    children: [
      {
        path: 'pro_add_del',
        name: '项目增删',
        component: _import('project/proaddel'),
        meta: {title: '项目增删', icon: 'example'},
        menu: 'pro_add_del'
      },
      {
        path: 'pro_approve',
        name: '项目审批',
        component: _import('project/proapprove'),
        meta: {title: '项目审批', icon: 'example'},
        menu: 'pro_update'
      }
    ]
  },
  {
    path: '/log',
    component: Layout,
    redirect: '/log/',
    name: 'log',
    children: [
      {
        path: '', 
        name: '日志', 
        component: _import('log/log'), 
        meta: {title: '日志', icon: 'log'}, 
        menu: 'log'
      }
    ]
  },
  {
    path: '/db',
    component: Layout,
    redirect: '/db/',
    name: 'db',
    meta: {title: '数据库管理', icon: 'table'},
    children: [
      {
        path: '', 
        name: '数据库操作', 
        component: _import('db/db'), 
        meta: {title: '数据库操作', icon: 'user'}, 
        menu: 'db'
      }
    ]
  },
  {
    path: '/data',
    component: Layout,
    redirect: '/data/',
    name: 'data',
    meta: {title: '数据分析', icon: 'table'},
    children: [
      {
        path: '', 
        name: '设备数据分析', 
        component: _import('data/devdata'), 
        meta: {title: '设备数据分析', icon: 'user'}, 
        menu: 'data_dev_admin'
      },
      {
        path: '', 
        name: '项目数据分析', 
        component: _import('data/prodata'), 
        meta: {title: '项目数据分析', icon: 'user'}, 
        menu: 'data_pro_admin'
      },

    ]
  },
  {
    path: '/reservation',
    component: Layout,
    name: 'reservation',
    meta: {title: '设备', icon: 'table'},
    children: [
      {
        path: 'dev_list', 
        name: '设备列表', 
        component: _import('reservation/index'), 
        meta: {title: '设备列表', icon: 'table'},
        menu: 'dev_list'
      },
      {
        path: 'dev_apply', 
        name: '申请预约', 
        component: _import('reservation/apply'), 
        meta: {title: '申请预约', icon: 'table'},
        menu: 'dev_apply'
      },
      {
        path: 'dev_my_list', 
        name: '我的预约', 
        component: _import('reservation/mybooking'), 
        meta: {title: '我的预约', icon: 'table'},
        menu: 'dev_my_list'
      },
      {
        path: 'dev_indexDemo', 
        name: '我的预约', 
        component: _import('reservation/indexDemo'), 
        meta: {title: '日历申请预约', icon: 'table'},
        menu: 'dev_indexDemo'
      }
    ]
  },
  {
    path: '/deviceuser',
    component: Layout,
    redirect: '/dev_maintain/',
    name: 'deviceuser',
    children: [
      {
        path: '', 
        name: '设备报修', 
        component: _import('deviceuser/deviceuser'), 
        meta: {title: '设备报修', icon: 'table'},
        menu: 'dev_maintain'
      }
    ]
  },
  {
    path: '/projectuser',
    component: Layout,
    redirect: '/projectuser/',
    name: 'projectuser',
    meta: {title: '项目', icon: 'table'},
    children: [
      {
        path: '', 
        name: '项目立项', 
        component: _import('projectuser/apply'), 
        meta: {title: '项目立项', icon: 'user'}, 
        menu: 'pro_apply'
      },
      {
        path: 'myprojectr', 
        name: '我的项目', 
        component: _import('projectuser/myproject'), 
        meta: {title: '我的项目', icon: 'user'}, 
        menu: 'pro_my_list'
      }
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]
